#ifndef LEDVIEW_H
#define LEDVIEW_H
#include <QPainter>
#include <QWidget>
#include <QEvent>
#include <QGraphicsItem>

class LedView : public QGraphicsItem
{
	int _x;
	int _y;
	QColor _col;
	int _startAngle;
	int _angleWidth;
	int _radius;
	QWidget* _parent;
	bool _hover;
	bool _active;
	QPoint _pointCenter;
	QPoint _gridPos;

public:
	LedView();
	LedView(int x, int y, int radius, int startAngle, int angleWidth, QWidget* parent = 0);
	void setColor(QColor col);

	QRectF boundingRect() const;
	QPainterPath shape() const;
	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
	void setPosition(int x, int y);
	void setDirection(int angle);
	void setAngleWidth(int width);
	void setGridPos(QPoint pt) {_gridPos = pt;}
	QPoint getGridPos() {return _gridPos;}

private:
	void drawLight(QPainter* painter);
	void drawPoint(QPainter* painter);
	void drawLightSelection(QPainter* painter);
	void drawPointSelection(QPainter* painter);

protected:
	void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
	void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
	void mousePressEvent(QGraphicsSceneMouseEvent *event);

public slots:
	//void onMouseHover(QEvent::Type type, const QPoint & pos, const QPoint & oldPos);
};

#endif // LEDVIEW_H
